using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.TestDrivens;
using Pixysoft.Framework.Configurations.Core;

namespace Pixysoft.Framework.Configurations.TestCases
{
    [TestDriven(TestDrivenType.IntegrationTest, "HtmlDocument")]
    class UnitTest_007_HtmlDocument
    {
        static IAssert assert = Assert.New(true);

        [TestStart]
        public static bool TestCaseStart()
        {

            return true;
        }

        [TestStop]
        public static void TestCaseStop()
        {
        }

        [TestStateSave]
        public static ITestDrivenDocument TestCaseStateSave()
        {
            return assert.Document;
        }


        [TestCase("Serialize")]
        public static void TestCase_000_Serialize()
        {
            string elementname = "element1";

            HtmlDocument doc = new HtmlDocument();
            doc.Nodes.Add(elementname, "id=\"id\"");
            doc.Nodes.Add(elementname, "id=\"id2\"");
            assert.IsEqual(2, doc.Nodes[elementname].Count);

            foreach (IHtmlNode node in doc.Nodes)
            {
                assert.Write(node.ElementName);
            }

            doc.Node[0].Node.Add(doc.Node[0]);
            assert.IsEqual(1, doc.Node[0].Node.Count);
            doc.Node[0].Node.RemoveAll();
            assert.IsEqual(0, doc.Node[0].Node.Count);

            doc.Node.AddDeclaration("helloworld");
            assert.Write(doc.Node[2]);
            assert.IsFalse(doc.Node[2].IsWellFormatted);

            assert.IsTrue(doc.Node.Contains(elementname));
            assert.IsTrue(doc.Nodes.Contains(elementname));

            assert.Write(doc.Serialize());
            assert.Write(doc.Serialize(true));


            Assert.Cache.Push(doc);
        }
    }
}
